<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>将汉字转为拼音的模块</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="050320.html">A trip to the Yellow Mountain</a>&nbsp;&nbsp;>>Next: <a href="EmailWithAttachment.html">发送邮件附件</a></p>
<h1>将汉字转为拼音的模块</h1>
<div class='content'>
<p>Category: <a href='MyCPAN.html'>MyCPAN</a> &nbsp; Keywords: <b>汉字 拼音</b></p><h2>Update</h2>
我更新了该模块，并将它改名为 Lingua::Han::PinYin <br>
详细的过程和用法查看：<a href='Han-PinYin.html'>重新写就的 Lingua::Han::PinYin</a><br />
<b>下面的已经不再使用了。</b>

<h2>说明</h2>
今天安装 <a href='http://search.cpan.org/perldoc?Unicode::Unihan'>Unicode::Unihan</a> 时，在其 srctxt 目录下找到个 汉字编码与拼音对照表 / Mandarin.txt 。<br>
另外发现在 gb2312 与 utf-8 下，汉字的编码是不相同的。<br>
所以就重写了一遍（从函数模块转为 OO ），并把 Light 版本删除掉。<br>
按此下载 <a href='http://www.fayland.org/CPAN/Lingua-Han2PinYin-0.06.tar.gz'>Lingua-Han2PinYin-0.06.tar.gz</a>

<h2>名称</h2>
Lingua::Han2PinYin - 将汉字转为它的拼音

<h2>例子</h2>
<pre>
use Lingua::Han2PinYin;
  
# 如果代码的编码为 gb2312, 默认
my $h2p = new Lingua::Han2PinYin();
print $h2p->han2pinyin("我");
  
# 如果代码编码为 utf-8
my $h2p = new Lingua::Han2PinYin(format => 'utf8');
print $h2p->han2pinyin("我");
</pre>

<h2>限制</h2>
不能处理多音字。

<h2>返回值</h2>
如果是一个常用字，返回它的拼音。<br>
如果不是，返回'XX'。

<h2>应用</h2>
查询汉字的拼音：<a href='http://www.1313s.com/cgi-bin/App.cgi?q=pinyin'>http://www.1313s.com/cgi-bin/App.cgi?q=pinyin</a></div>
<p><&lt;Previous: <a href="050320.html">A trip to the Yellow Mountain</a>&nbsp;&nbsp;>>Next: <a href="EmailWithAttachment.html">发送邮件附件</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=%E5%B0%86%E6%B1%89%E5%AD%97%E8%BD%AC%E4%B8%BA%E6%8B%BC%E9%9F%B3%E7%9A%84%E6%A8%A1%E5%9D%97&url=http://www.fayland.org/journal/Han2PinYin.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='ChineseCoding.html'>汉字编码笔记</a> < <span class='digit'>2004-11-23 13:23:11</span> ></li><li><a href='Lingua-Han-Utils.html'>针对汉字的 Lingua::Han::Utils</a> < <span class='digit'>2005-11-18 18:37:41</span> ></li><li><a href='Lingua-Han-Stroke.html'>汉字比划模块</a> < <span class='digit'>2005-11-18 20:27:49</span> ></li></ul>
Created on <span class="digit">2004-12-06 22:36:39</span>, Last modified on <span class="digit">2005-11-18 20:46:40</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>